QuickTime 4 API Documentation

3D Graphics Programming with QuickDraw 3D 1.5.4

Previous | QD3D Book | Overview | Chapter Contents | Next |

Creating a Light

You create a light by filling in the fields of the data structure for the type of light you want to create and then by calling a QuickDraw 3D function to create the light. For example, to create a point light, you fill in a data structure of type TQ3PointLightData and then call Q3PointLight_New , as shown in Listing 1 .

Listing 1 Creating a new point light

TQ3LightObject MyNewPointLight (void)
{
    TQ3LightData                    myLightData;
    TQ3PointLightData               myPointLightData;
    TQ3LightObject                  myPointLight;
    TQ3Point3D                      pointLocation = {-20.0, 0.0, 20.0};
    TQ3ColorRGB                     WhiteLight = { 1.0, 1.0, 1.0 };

    /*Set up light data for a point light.*/
    myLightData.isOn = kQ3True;
    myLightData.brightness = 1.0;
    myLightData.color = WhiteLight;
    myPointLightData.lightData = myLightData;
    myPointLightData.castsShadows = kQ3False;
    myPointLightData.attenuation = kQ3AttenuationTypeNone;
    myPointLightData.location = pointLocation;

    /*Create a point light.*/
    myPointLight = Q3PointLight_New(&myPointLightData);
    return (myPointLight);
}

As you can see, the MyNewPointLight function defined in Listing 1 simply fills in the myPointLight structure and then calls Q3PointLight_New . MyNewPointLight returns to its caller either a reference to the new light (if Q3PointLight_New succeeds) or the value NULL (if Q3PointLight_New fails).


© 1997 Apple Computer, Inc.

Previous | QD3D Book | Overview | Chapter Contents | Next |